Skip to content

De-abstract Savable by making it a protocol#298

Closed
unkcpz wants to merge 47 commits intoaiidateam:masterfrom
unkcpz:deab-savable-inh
Closed

De-abstract Savable by making it a protocol#298
unkcpz wants to merge 47 commits intoaiidateam:masterfrom
unkcpz:deab-savable-inh

Conversation

@unkcpz
Copy link
Member

@unkcpz unkcpz commented Dec 12, 2024

The outcome of this refactoring is that the Savable become a protocol which provide the contract for how things needed to be saved should implemented.

@runtime_checkable
class Savable(Protocol):
    @classmethod
    def recreate_from(cls, saved_state: SAVED_STATE_TYPE, load_context: LoadSaveContext | None = None) -> 'Savable':
        """
        Recreate a :class:`Savable` from a saved state using an optional load context.

        :param saved_state: The saved state
        :param load_context: An optional load context

        :return: The recreated instance

        """
        ...

    def save(self, save_context: LoadSaveContext | None = None) -> SAVED_STATE_TYPE: ...

Compare to the original implementation where save calls save_instance_state calls each other recursively until all savable things is saved, the new implementation force the save method independent and have symmetry behavior of recreate_from.

unkcpz#5

@unkcpz unkcpz marked this pull request as draft December 12, 2024 11:04
@unkcpz unkcpz force-pushed the deab-savable-inh branch 5 times, most recently from 34d9b01 to d524e63 Compare January 18, 2025 01:59
@unkcpz unkcpz changed the base branch from dev to master January 18, 2025 02:04
@unkcpz unkcpz force-pushed the deab-savable-inh branch 2 times, most recently from e149bd2 to a90dcff Compare January 22, 2025 10:04
@unkcpz
Copy link
Member Author

unkcpz commented Oct 13, 2025

Not planed anymore.

@unkcpz unkcpz closed this Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant